package api_.collectionTest.queue;

import java.util.ArrayDeque;
import java.util.LinkedList;
import java.util.Queue;

public class QueueTest
{
    public static void main(String[] args)
    {
        Queue queue = new LinkedList();
//        queue.add(1);
//        queue.add(2);
//        queue.add(3);
//        queue.add(4);
//        System.out.println(queue.remove());
//        System.out.println(queue.remove());
//        System.out.println(queue.remove());
//        System.out.println(queue.remove());
//        System.out.println(queue.remove());
        queue.offer(1);  // 满了会返回false
        queue.offer(2);
        queue.offer(3);
        queue.offer(4);
        queue.offer(5);

        System.out.println(queue.poll());  // 删除第一个，在队列为空时返回false
        System.out.println(queue.poll());
        System.out.println(queue.poll());
        System.out.println(queue.poll());
        System.out.println(queue.poll());


        ArrayDeque arrayDeque = new ArrayDeque();
        arrayDeque.addFirst(1);
        arrayDeque.addLast(2);
        arrayDeque.addFirst(3);
        arrayDeque.offer(4);
        System.out.println(arrayDeque);
        System.out.println(arrayDeque.peek());  // 访问第一个 不删除
        System.out.println("------------------------------------------");
        System.out.println(arrayDeque.removeFirst());
        System.out.println(arrayDeque.removeLast());
        System.out.println(arrayDeque.removeFirst());
//        System.out.println(arrayDeque.removeFirst());
         ;
    }

}
